package File;

import java.io.*;

public class file2 {
    static String path = "java语法\\src\\File\\Files";

    public static void main(String[] args) throws IOException {
        checkNum();
    }

    /**
     * 判断文件内数字是否小于三
     */
    public static void checkNum() throws IOException {
        File file = new File(path, "count.txt");
        if (!file.exists()) {
            file.createNewFile();
            FileWriter writer = new FileWriter(file);
            writer.write('0');
            writer.close();
        }
        BufferedReader reader = new BufferedReader(new FileReader(file));
        int count = Integer.parseInt(reader.readLine());
        reader.close();
        if (count < 3) {
            System.out.println(count + "小于3");
        } else {
            System.out.println(count + "大于等于3 ");
        }
        BufferedWriter writer = new BufferedWriter(new FileWriter(file));
        count++;
        writer.write(count + "");
        writer.close();
    }
}
